import request from '../utils/request'

/**
 * 获取用户数据列表
 * @param {Object} params {query, pagenum, pagesize}
 * @returns promise
 */
export const getUsersListAPI = params => request({
    url:'users',
    params
})

/**
 * 添加用户
 * @param {Object} data {username, password, email, mobile}
 * @returns promise
 */
export const addUserAPI = data => request({
    url:'users',
    method:'POST',
    data
})

/**
 * 编辑用户
 * @param {Object} data {id, email, mobile}
 * @returns promise
 */
export const editUserAPI = data => request({
    method:'PUT',
    url:`users/${data.id}`,
    data:{
        email:data.email,
        mobile:data.mobile
    }
})

/**
 * 删除单个用户
 * @param {Number} id 当前用户id
 * @returns promise
 */
export const deleteUserAPI = id => request({
    method:'DELETE',
    url:`users/${id}`
})